/**  
 * All rights Reserved, Designed By <a href="www.itttq.com" target="_blank">www.itttq.com</a>
 * @date:   2017-07-21 11:42:21
 * @Copyright: 2017 <a href="www.itttq.com" target="_blank">www.itttq.com</a> Inc. All rights reserved. 
 */
package com.itttq.gshop.pc.controller.sys;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import com.itttq.gshop.domain.po.SysNoticePo;
import com.itttq.gshop.generic.connector.ISysNoticeConnector;
import com.itttq.gshop.pc.controller.GenericPcController;
@RestController
@RequestMapping("notice")
public class NoticeController extends GenericPcController {
	private static final long serialVersionUID = -6485775841311449L;
	public static final String cacheKey = "notice";
	@Autowired
	private ISysNoticeConnector noticeConnector;
	/**
	 * 获取公告列表
	 * 
	 * @param request
	 * @Author 迷蝶
	 * @return ModelAndView
	 */
	@RequestMapping("list.html")
    public ModelAndView getAddresses(HttpServletRequest request) {
		ModelAndView mv = new ModelAndView("/sys/notices");
		SysNoticePo notice = new SysNoticePo();
		this.setPpt(request, notice);
		mv.addObject("notices", noticeConnector.getSysNotices(notice).getData());
		getCommon(request, mv);
        return mv;
    }
	/**
	 * 根据ID获取公告内容
	 * 
	 * @param id
	 * @Author 迷蝶
	 * @return ModelAndView
	 */
	@RequestMapping("{id}.html")
	public ModelAndView getUserAddressById(@PathVariable("id") int id, HttpServletRequest request) {
		ModelAndView mv = new ModelAndView("/sys/notice");
		mv.addObject("notice", noticeConnector.getSysNotice(id));
		getCommon(request, mv);
        return mv;
	}
}